/**
 * Created by joustany on 17/12/20.
 */
var params = JSON.parse(window.localStorage.user);
var redirect = JSON.parse(decodeURIComponent(params['redirect']));
var order = $.urlGet().order_no

$.ajax({
    url: configApi('/deposit/view'),
    data: {
        access_token: redirect.token,
        order_no:order
    },
    dataType: 'json',
    type: "get",
    success: function (res) {
        if (res.success) {
            var data = res.data
            getShowView(data)
            _hmt.push(["_trackEvent", "充值", "充值成功","",data.amount]);
        } else {
            layer.open({
                content: res.message
                , skin: 'msg'
                , time: 2 //2秒后自动关闭
            });
        }
    },
    error: function () {
        layer.open({
            content: "服务器异常,请退出重试"
            , skin: 'msg'
            , time: 2 //2秒后自动关闭
        });
    }
})
function getShowView(data) {
    $('.result-num .num').text(data.amount)
    console.log(data)
    if(window.localStorage.top && data.amount === 1000){
        $('.result-yet').html('<span class="num">' +
            // ''+ data.give_amount +'' +
            '</span>赠送礼包已下单会有客服联系您<br><br>并获得了新人6元大红包<br>可以前往"我的-红包"查看')
        window.localStorage.removeItem('top')
    }else if (data.amount === 1000){
        $('.result-yet').html('<span class="num">' +
            // ''+ data.give_amount +'' +
            '</span>赠送礼包已下单会有客服联系您')
    }else {
        if (data.amount === 1000){
            $('.result-yet').html('<span class="num">' +
                // ''+ data.give_amount +'' +
                '</span>赠送礼包已下单会有客服联系您')
        }else {
            if(window.localStorage.top){
                $('.result-yet').html('<span class="num">'+ data.give_amount +'</span>元红包已经发放<br>并获得了新人6元大红包<br>可以前往"我的-红包"查看')
                window.localStorage.removeItem('top')
            }else {
                $('.result-yet').html('<span class="num">'+ data.give_amount +'</span>元红包已经发放<br>可以前往"我的-红包"查看')
            }
        }
    }
}
//返回个人中心
function meHandle() {
    window.location.href = './me.html'
}
//返回首页
function indexHandle() {
    window.location.href = './index.html'
}
